{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example of loading a custom tree model into SHAP\n", "\n", "This notebook shows how to pass a custom tree ensemble model into SHAP for explanation." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import graphviz\n", "import numpy as np\n", "import scipy\n", "import sklearn\n", "\n", "import shap" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simple regression tree model\n", "\n", "Here we define a simple regression tree and then load it into SHAP as a custom model." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
DecisionTreeRegressor(max_depth=2)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
DecisionTreeRegressor(max_depth=2)
GradientBoostingClassifier(n_estimators=2)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
GradientBoostingClassifier(n_estimators=2)